package com.neouton.crm.op.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neouton.common.util.PageUtil;
import com.neouton.common.util.ResponseAPI;
import com.neouton.crm.approval.entity.ApprovalVO;
import com.neouton.crm.entity.SysUserEntity;
import com.neouton.crm.op.entity.SalesOpportunityVO;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

public interface SalesOpportunityService {

    PageUtil<SalesOpportunityVO> queryOpportunity(IPage<SalesOpportunityVO> page, SalesOpportunityVO opportunityVO, List<SysUserEntity> userList, String token);

    PageUtil<SalesOpportunityVO> queryOpportunityAudit(IPage<SalesOpportunityVO> page, SalesOpportunityVO opportunityVO, List<SysUserEntity> userList, String token);

    PageUtil<SalesOpportunityVO> queryOpportunityAuditOne(IPage<SalesOpportunityVO> page, SalesOpportunityVO opportunityVO, List<SysUserEntity> userList, String token);

    PageUtil<SalesOpportunityVO> queryToDoList(IPage<SalesOpportunityVO> page, SalesOpportunityVO opportunityVO);
    List<SalesOpportunityVO> queryOpportunity(SalesOpportunityVO opportunityVO, List<SysUserEntity> userList, String token);

    List<SalesOpportunityVO> selectAllOpInfo(SalesOpportunityVO record);

    boolean updateByPrimaryKey(SalesOpportunityVO record);

    /**
     * 提交审核
     */
    SalesOpportunityVO commitStateChangeToAudit(SalesOpportunityVO op, String token);

    /**
     * 机会阶段变更审批通过
     */
    boolean approveStateChange(SalesOpportunityVO op, String token, Boolean auto);

    /**
     * 机会阶段变更审批驳回
     */
    boolean rejectStateChange(SalesOpportunityVO op, String token);

    /**
     * 机会点逻辑删除
     * @param opId 机会ID
     */
    boolean logicDelete(Integer opId);

    SalesOpportunityVO queryOpportunityById(Integer opId);

    SalesOpportunityVO queryOpportunityAllById(Integer opId);

    void createRecord(SalesOpportunityVO oldOp,SalesOpportunityVO newOp, String token);

    /**
     * 机会点保存
     */
    ResponseAPI saveOpportunity(SalesOpportunityVO record, String token);

    /**
     * 机会点保存
     */
    ResponseAPI updateOpportunityByCreate(SalesOpportunityVO record, String token);

    void exportOpportunityInfo(HttpServletResponse response, List<SalesOpportunityVO> list, String token) throws Exception;

    SalesOpportunityVO queryOpportunityByBusinessId(Integer workId);

    SalesOpportunityVO queryHistoryOpportunityByApprovalId(Integer workId);

    void opportunityWithdrawal(ApprovalVO approval, String token);

    /**
     * 更具ID获取机会负责人信息
     *
     * @return
     */
     SysUserEntity queryOpportunityHeadByProjectId(Integer opportunityId,String token);

    SalesOpportunityVO queryOpportunityByApprovalId(Integer approvalId);

    SalesOpportunityVO queryOpportunityHistoryByApprovalId(Integer approvalId);

    boolean approveCreateOp(SalesOpportunityVO op, String token, boolean auto);


    boolean rejectCreateOp(SalesOpportunityVO op, String token);

    int transforPrincipal(Integer userId, List<SalesOpportunityVO> voList, String token);
}
